package com.msk.common.constant;

import io.jsonwebtoken.Claims;

/**
 * 通用常量信息
 *
 * @author msk
 */
public class Constants {
    /**
     * UTF-8 字符集
     */
    public static final String UTF8 = "UTF-8";

    /**
     * GBK 字符集
     */
    public static final String GBK = "GBK";

    /**
     * www主域
     */
    public static final String WWW = "www.";

    /**
     * http请求
     */
    public static final String HTTP = "http://";

    /**
     * https请求
     */
    public static final String HTTPS = "https://";

    /**
     * 通用成功标识
     */
    public static final String SUCCESS = "0";

    /**
     * 通用成功标识
     */
    public static final int SUCCESS_R = 200;

    /**
     * 通用失败标识
     */
    public static final String FAIL = "1";

    /**
     * 通用失败标识
     */
    public static final int FAIL_R = 1;

    /**
     * 成功标记
     */
    public static final Integer SUCCESS_APP = 0;

    /**
     * 登录成功
     */
    public static final String LOGIN_SUCCESS = "Success";


    /**
     * 失败标记
     */
    public static final Integer APP_STUDENT_FAIL = 2006;

    /**
     * 失败标记
     */
    public static final Integer APP_TEACHER_FAIL = 2005;

    /**
     * 失败标记
     */
    public static final Integer MP_ALLIANCE_FAIL = 2007;

    /**
     * APP Token失败标记
     */
    public static final Integer APP_TOKEN_FAIL = 2999;

    /**
     * 注销
     */
    public static final String LOGOUT = "Logout";

    /**
     * 注册
     */
    public static final String REGISTER = "Register";

    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL = "Error";

    /**
     * 验证码 redis key
     */
    public static final String CAPTCHA_CODE_KEY = "captcha_codes:";

    /**
     * 后台登录用户 redis key
     */
    public static final String LOGIN_TOKEN_KEY = "login_tokens:";

    /**
     * 微信小程序用户 redis key
     */
    public static final String LOGIN_MP_TOKEN_KEY = "login_mp_tokens:";
    /**
     * 前台登录用户 redis key
     */
    public static final String WEB_LOGIN_TOKEN_KEY = "web_login_tokens:";

    /**
     * 防重提交 redis key
     */
    public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";

    /**
     * 限流 redis key
     */
    public static final String RATE_LIMIT_KEY = "rate_limit:";

    /**
     * 验证码有效期（分钟）
     */
    public static final Integer CAPTCHA_EXPIRATION = 2;

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

    public static final String LOGIN_MP_USER_KEY = "login_mp_user_key";

    /**
     * 用户ID
     */
    public static final String JWT_USERID = "userid";

    /**
     * 用户名称
     */
    public static final String JWT_USERNAME = Claims.SUBJECT;

    /**
     * 用户头像
     */
    public static final String JWT_AVATAR = "avatar";

    /**
     * 创建时间
     */
    public static final String JWT_CREATED = "created";

    /**
     * 用户权限
     */
    public static final String JWT_AUTHORITIES = "authorities";

    /**
     * 参数管理 cache key
     */
    public static final String SYS_CONFIG_KEY = "sys_config:";

    /**
     * 字典管理 cache key
     */
    public static final String SYS_DICT_KEY = "sys_dict:";

    /**
     * 资源映射路径 前缀
     */
    public static final String RESOURCE_PREFIX = "/profile";

    /**
     * RMI 远程方法调用
     */
    public static final String LOOKUP_RMI = "rmi:";

    /**
     * LDAP 远程方法调用
     */
    public static final String LOOKUP_LDAP = "ldap:";

    /**
     * LDAPS 远程方法调用
     */
    public static final String LOOKUP_LDAPS = "ldaps:";

    /**
     * 定时任务白名单配置（仅允许访问的包名，如其他需要可以自行添加）
     */
    public static final String[] JOB_WHITELIST_STR = {"com.msk"};

    /**
     * 定时任务违规的字符
     */
    public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
            "org.springframework", "org.apache", "com.msk.common.utils.file", "com.msk.common.config"};


    /**
     * 手机验证码 phoneCode key
     */
    public static final String SYS_PHONE_CODE_KEY = "msk_phone_code_key:";

    /**
     * 手机验证码发送次数 Verification code count key
     */
    public static final String SYS_PHONE_CODE_COUNT_KEY = "msk_phone_code_count_key:";

    /**
     * 首页轮播图
     */
    public static final String HOME_PAGE_CAROUSEL = "home_page:home_page_carousel";

    /**
     * 当前记录起始索引
     */
    public static final String PAGE_NUM = "pageNum";

    /**
     * 每页显示记录数
     */
    public static final String PAGE_SIZE = "pageSize";

    /**
     * 排序列
     */
    public static final String ORDER_BY_COLUMN = "orderByColumn";

    /**
     * 排序的方向 "desc" 或者 "asc".
     */
    public static final String IS_ASC = "isAsc";

    /**
     * 令牌有效期（分钟）
     */
    public final static long TOKEN_EXPIRE = 4 * 30;


    /**
     * APP令牌有效期（分钟）
     */
    public final static long TOKEN_APP_EXPIRE = 365 * 24 * 60;

    /**
     * H5令牌有效期（分钟）
     */
    public final static long TOKEN_H5_EXPIRE = 7 * 24 * 60;

    /**
     * 系统内部使用令牌有效期
     */
    public final static long SYSTEM_INSIDE_TOKEN_EXPIRE = 365 * 24 * 60 * 60;

    /**
     * 消息模板 cache key
     */
    public static final String SYS_MESSAGE_TEMPLATE_KEY = "msk_message_template_key:";

    /**
     * 用户身份切换 phoneCode key
     */
    public static final String SYS_IDENTITY_CODE = "msk_identity_code_key";

    /**
     * 默认编号 cache key
     * default
     */
    public static final String SYS_DEFAULT_NO_KEY = "msk_default_no_key:";

    /**
     * 系统定时消息 cache key
     * default
     */
    public static final String MSK_MESSAGE_KEY = "msk_message:message_key";


    /**
     * 首页消息
     */
    public static final String HOME_PAGE_MESSAGE = "home_page:home_page_message";

    /**
     * 锁的key前缀
     */
    public static final String LOCK_STR = "r_lock_";

    /**
     * 字典管理 cache key
     */
    public static final String JOB_DICT_KEY = "msk_job_dict:";

    /**
     * 参数管理 cache key
     */
    public static final String SYS_CODERULS_KEY = "msk_coderules_config:";

}
